package cn.dengta.webapp.trade.dto;

import java.math.BigDecimal;

import cn.dengta.webapp.base.vo.AbstractVO;
import cn.dengta.webapp.trade.entity.UserIntegralLog;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.X;

@Getter
@Setter
@Accessors(chain = true)
public class UserIntegralLogSumDTO extends AbstractVO<UserIntegralLog> {

	/** 用户ID */
	public Long userId;
	/** to用户ID */
	public Long toUserId;
	/** 用户数 */
	public Integer userCount;
	/** 来源用户数 */
	public Integer toUserCount;
	/** 业务类型 TradeType */
	protected String tradeType;
	/** 钻石来源业务类型 */
	protected String coinTradeType;
	/** 交易总金额 */
	public BigDecimal totalTradeAmount;
	/** 总金额 */
	public BigDecimal totalAmount;
	/** 总充值金额 */
	public BigDecimal rechargeAmount;
	/** 钻石来源数量 */
	public Integer coinTypeCount;
	/** 消耗钻石数 */
	public Long totalTradeCoin;
	public Long totalFreeTradeCoin;
	public String selectKey;
	// 收益类型（作为载体）
	/** 搭讪收益 */
	public BigDecimal greetIntegral;
	/** 聊天收益 */
	public BigDecimal msgIntegral;
	/** 语音收益 */
	public BigDecimal audioIntegral;
	/** 视频收益 */
	public BigDecimal videoIntegral;
	/** 1v1礼物收益 */
	public BigDecimal giftIntegral;
	/** 背包礼物收益 */
	public BigDecimal giftBagIntegral;
	/** 直播礼物收益 */
	public BigDecimal giftLiveIntegral;
	/** 礼物总收益 */
	public BigDecimal giftTotalIntegral;
	/** 充值收益 */
	public BigDecimal rechargeIntegral;
	// 收益来源类型（作为载体）
	/** 搭讪总钻石 */
	public Long greetCoin;
	/** 聊天总钻石 */
	public Long msgCoin;
	/** 语音总钻石 */
	public Long audioCoin;
	/** 视频总钻石 */
	public Long videoCoin;
	/** 1v1礼物钻石 */
	public Long giftCoin;
	/** 直播礼物总钻石 */
	public Long giftLiveCoin;
	/** 礼物总钻石 */
	public Long giftTotalCoin;
	/** 一级推广员 */
	private Long agentId;
	/** 二级推广员 */
	private Long agent2Id;

	public UserIntegralLogSumDTO initTypeIntegral(BigDecimal greetIntegral, BigDecimal msgIntegral, BigDecimal audioIntegral, BigDecimal videoIntegral, BigDecimal giftIntegral, BigDecimal giftLiveIntegral) {
		this.greetIntegral = X.expectNotNull(greetIntegral, BigDecimal.ZERO);
		this.msgIntegral = X.expectNotNull(msgIntegral, BigDecimal.ZERO);
		this.audioIntegral = X.expectNotNull(audioIntegral, BigDecimal.ZERO);
		this.videoIntegral = X.expectNotNull(videoIntegral, BigDecimal.ZERO);
		this.giftIntegral = X.expectNotNull(giftIntegral, BigDecimal.ZERO);
		this.giftLiveIntegral = X.expectNotNull(giftLiveIntegral, BigDecimal.ZERO);
		this.giftTotalIntegral = this.giftIntegral.add(this.giftLiveIntegral);
		return this;
	}

	public BigDecimal getTotalTradeAmountTurnZero() {
		return totalTradeAmount != null ? totalTradeAmount : BigDecimal.ZERO;
	}

}
